import { createRouter, createWebHistory } from 'vue-router'
import { ref } from 'vue'
import Login from '../components/Login.vue'
import App from '../App.vue'

// 创建一个简单的状态管理，在实际项目中您可能希望使用Vuex或Pinia
export const isAuthenticated = ref(false)

const routes = [
  {
    path: '/',
    name: 'Home',
    component: App,
    meta: { requiresAuth: true }
  },
  {
    path: '/task-distribution',
    name: 'TaskDistribution',
    component: () => import('../components/TaskDistribution.vue'),
    props: true
  }
]

const router = createRouter({
  history: createWebHistory(),
  routes
})


// 添加全局导航守卫来处理组件切换
router.beforeEach((to, from, next) => {
  // 清理任何可能的全局状态
  next();
});

export default router